import React from "react";

import Form from "../Form";

// 高阶组件
function formHOC(Component) {
    class WrappedComponent extends React.Component {
        
      static defaultProps = {
        defaultUsername: "新的默认值",
      };

      sayHello = () => {
        alert("Hello");
      };

        render() {
      const { title, ...restProps } = this.props;
      return (
        <>
          <h2>{title}</h2>
          {/* <Component btnText={btnText} defaultUsername="默认值" /> */}
          <Component
            {...restProps}
            sayHello={this.sayHello}
            defaultUsername="绝对优先级" />
        </>
      );
    }
  }

  return WrappedComponent;
}

const NewForm = formHOC(Form);

export default NewForm;
